package daily.jun0604;

public class ThreadPriorityTest {
    public static void main(String[] args) {
        //创建两个线程，使用Lambda表达式
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + "正在执行，我是优先级高的");
            }
        });
        //设置线程优先级10
        thread1.setPriority(10);
        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName() + "正在执行，我是优先级低的");
            }
        });
        //设置线程优先级1
        thread2.setPriority(Thread.MIN_PRIORITY);
        thread1.start();
        thread2.start();
    }
}
